package com.fr.base.core.serializable;

import com.fr.base.core.ComparatorUtils;
import java.io.Serializable;
import java.text.Collator;
import java.util.Comparator;
import java.util.Locale;

public class SerialableLocalCollator
  implements Comparator, Serializable
{
  private Locale locale = null;
  private transient Collator collator = null;

  public SerialableLocalCollator(Locale paramLocale)
  {
    setLocale(paramLocale);
  }

  public int compare(Object paramObject1, Object paramObject2)
  {
    return ComparatorUtils.compare(getCollator(), paramObject1, paramObject2);
  }

  public Locale getLocale()
  {
    return this.locale;
  }

  public void setLocale(Locale paramLocale)
  {
    this.locale = paramLocale;
    this.collator = null;
  }

  private Collator getCollator()
  {
    if (this.collator == null)
      if (getLocale() == null)
        this.collator = Collator.getInstance();
      else
        this.collator = Collator.getInstance(getLocale());
    return this.collator;
  }
}